package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CcsStudentTeachingClass;
import com.ruoyi.system.service.ICcsStudentTeachingClassService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生教学班级管理Controller
 * 
 * @author ruoyi
 * @date 2024-04-26
 */
@RestController
@RequestMapping("/system/student_class")
public class CcsStudentTeachingClassController extends BaseController
{
    @Autowired
    private ICcsStudentTeachingClassService ccsStudentTeachingClassService;

    /**
     * 查询学生教学班级管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:student_class:list')")
    @GetMapping("/list")
    public TableDataInfo list(CcsStudentTeachingClass ccsStudentTeachingClass)
    {
        startPage();
        List<CcsStudentTeachingClass> list = ccsStudentTeachingClassService.selectCcsStudentTeachingClassList(ccsStudentTeachingClass);
        return getDataTable(list);
    }

    /**
     * 导出学生教学班级管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:student_class:export')")
    @Log(title = "学生教学班级管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CcsStudentTeachingClass ccsStudentTeachingClass)
    {
        List<CcsStudentTeachingClass> list = ccsStudentTeachingClassService.selectCcsStudentTeachingClassList(ccsStudentTeachingClass);
        ExcelUtil<CcsStudentTeachingClass> util = new ExcelUtil<CcsStudentTeachingClass>(CcsStudentTeachingClass.class);
        util.exportExcel(response, list, "学生教学班级管理数据");
    }

    /**
     * 获取学生教学班级管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:student_class:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ccsStudentTeachingClassService.selectCcsStudentTeachingClassById(id));
    }

    /**
     * 新增学生教学班级管理
     */
    @PreAuthorize("@ss.hasPermi('system:student_class:add')")
    @Log(title = "学生教学班级管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CcsStudentTeachingClass ccsStudentTeachingClass)
    {
        return toAjax(ccsStudentTeachingClassService.insertCcsStudentTeachingClass(ccsStudentTeachingClass));
    }

    /**
     * 修改学生教学班级管理
     */
    @PreAuthorize("@ss.hasPermi('system:student_class:edit')")
    @Log(title = "学生教学班级管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CcsStudentTeachingClass ccsStudentTeachingClass)
    {
        return toAjax(ccsStudentTeachingClassService.updateCcsStudentTeachingClass(ccsStudentTeachingClass));
    }

    /**
     * 删除学生教学班级管理
     */
    @PreAuthorize("@ss.hasPermi('system:student_class:remove')")
    @Log(title = "学生教学班级管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ccsStudentTeachingClassService.deleteCcsStudentTeachingClassByIds(ids));
    }
}
